cmake_minimum_required(VERSION 3.6)

project(serverframework)
include_directories(.)
include_directories(../include)
#add_subdirectory(../Tool Tool)
#add_subdirectory(ServerMod)
add_library(${PROJECT_NAME} STATIC
        NetWork/NetworkManager.cpp
        NetWork/Connection.cpp
        BaseMod.cpp
        ModManager.cpp
        AppManager.cpp)

target_link_libraries(${PROJECT_NAME} Tool boost_strip glog)
target_include_directories(${PROJECT_NAME}
        PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        $<INSTALL_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../include
        $<INSTALL_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/../include
        )

IF (WIN32)
    MESSAGE(STATUS "Now is windows")

    #    add_definitions(-D_WIN32 -DWIN32 -DUNICODE -D_UNICODE)
    #    add_definitions(-D_CRT_NO_VA_START_VALIDATION -D_CRT_SECURE_NO_WARNINGS)
    #    add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX -DBUILDING_IM_CORE)

    set(CompilerFlags
            CMAKE_CXX_FLAGS
            CMAKE_CXX_FLAGS_DEBUG
            CMAKE_CXX_FLAGS_RELEASE
            CMAKE_C_FLAGS
            CMAKE_C_FLAGS_DEBUG
            CMAKE_C_FLAGS_RELEASE)

    foreach (CompilerFlag ${CompilerFlags})
        string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
    endforeach ()
    target_link_libraries(${PROJECT_NAME}
            ws2_32
            mswsock
            )
ELSEIF (APPLE)
    MESSAGE(STATUS "Now is Apple systens.")
ELSEIF (UNIX)
    MESSAGE(STATUS "Now is UNIX-like OS's.")
ENDIF ()

install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}.out/lib)
